package com.ms.game.bank.db;

import java.math.BigDecimal;
import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;

import org.hibernate.annotations.Index;

import com.xpec.c4.db.model.log.basic.BasicTransactionLogModel;
import com.xpec.c4.game.common.Helper;

@Entity
@Table(name="bank_log")
@org.hibernate.annotations.Table(
		appliesTo = "bank_log", 
		indexes = {
			@Index(name = "IDX_BANKBOOK", columnNames = { "playerId", "gameTime" }),
		})
public class BankLogModel extends BasicTransactionLogModel {

	private static final long serialVersionUID = -1122537732927937117L;
		
	/** account guid */
	private String accountId;

	/** player guid */
	private String playerId;

	/** player name */
	private String playerName;
	
	/** upline name 
	 *	抽傭或是邀請獎勵 要顯示下線的名稱  
	 **/
	private String downlineName;

	/** 金幣 異動數值 */
	private BigDecimal goldChangeValue;
	
	/** 金幣 異動前數值 */
	private BigDecimal goldBeforeChange;

	/** 金幣 變更後數值 */
	private BigDecimal goldAfterChange;
	
	/**銀行金幣 異動值**/
	private BigDecimal bankGoldChangeValue;

	/**銀行金幣 異動值**/
	private BigDecimal bankGoldBeforeChange;
	
	/**銀行金幣 異動值**/
	private BigDecimal bankGoldAfterChange;
	
	/**哪一天的回饋金 */
	private Date rebateBelongsDate;

	/** 行為id */
	private int changeWay;

	/** 行為說明 */
	private String changeWayDesc;

	public String getAccountId() {
		return accountId;
	}

	public String getPlayerId() {
		return playerId;
	}

	public String getPlayerName() {
		return playerName;
	}

	@Column(precision = 19, scale = 2, columnDefinition = "DECIMAL(19,2) default 0.0")
	public BigDecimal getGoldChangeValue() {
		return goldChangeValue;
	}

	@Column(precision = 19, scale = 2, columnDefinition = "DECIMAL(19,2) default 0.0")
	public BigDecimal getGoldBeforeChange() {
		return goldBeforeChange;
	}

	@Column(precision = 19, scale = 2, columnDefinition = "DECIMAL(19,2) default 0.0")
	public BigDecimal getGoldAfterChange() {
		return goldAfterChange;
	}

	public int getChangeWay() {
		return changeWay;
	}

	public String getChangeWayDesc() {
		return changeWayDesc;
	}

	@Column(precision = 19, scale = 2, columnDefinition = "DECIMAL(19,2) default 0.0")
	public BigDecimal getBankGoldChangeValue() {
		return bankGoldChangeValue;
	}

	@Column(precision = 19, scale = 2, columnDefinition = "DECIMAL(19,2) default 0.0")
	public BigDecimal getBankGoldBeforeChange() {
		return bankGoldBeforeChange;
	}

	@Column(precision = 19, scale = 2, columnDefinition = "DECIMAL(19,2) default 0.0")
	public BigDecimal getBankGoldAfterChange() {
		return bankGoldAfterChange;
	}

	public void setAccountId(String accountId) {
		this.accountId = accountId;
	}

	public void setPlayerId(String playerId) {
		this.playerId = playerId;
	}

	public void setPlayerName(String playerName) {
		this.playerName = playerName;
	}
	
	//set GoldChangeValue with long
	public void setGoldChangeValue(long goldChangeValue) {
		BigDecimal decimalGoldCoin = Helper.sub(this.goldChangeValue, new BigDecimal(this.goldChangeValue.longValue()));
		this.goldChangeValue = new BigDecimal(goldChangeValue);
	}
	
	//set GoldChangeValue with bigdecimal
	public void setGoldChangeValue(BigDecimal goldChangeValue) {
		this.goldChangeValue = goldChangeValue;
	}
	
	//set GoldBeforeChange with long
	public void setGoldBeforeChange(long goldBeforeChange) {
		BigDecimal decimalGoldCoin = Helper.sub(this.goldBeforeChange, new BigDecimal(this.goldBeforeChange.longValue()));
		this.goldBeforeChange = Helper.add(new BigDecimal(goldBeforeChange), decimalGoldCoin);
	}

	//set GoldBeforeChange with bigdecimal
	public void setGoldBeforeChange(BigDecimal goldBeforeChange) {
		this.goldBeforeChange = goldBeforeChange;
	}
	
	//set GoldAfterChange with long
	public void setGoldAfterChange(long goldAfterChange) {
		BigDecimal decimalGoldCoin = Helper.sub(this.goldAfterChange, new BigDecimal(this.goldAfterChange.longValue()));
		this.goldAfterChange = Helper.add(new BigDecimal(goldAfterChange), decimalGoldCoin);
	}
	
	//set GoldAfterChange with bigdecimal
	public void setGoldAfterChange(BigDecimal goldAfterChange) {
		this.goldAfterChange = goldAfterChange;
	}

	//set BankGoldChangeValue with long value
	public void setBankGoldChangeValue(long bankGoldChangeValue) {
		BigDecimal decimalGoldCoin = Helper.sub(this.bankGoldChangeValue, new BigDecimal(this.bankGoldChangeValue.longValue()));
		this.bankGoldChangeValue = Helper.add(new BigDecimal(bankGoldChangeValue), decimalGoldCoin);
	}
	
	//set BankGoldChangeValue with  bigdecimal 
	public void setBankGoldChangeValue(BigDecimal bankGoldChangeValue) {
		this.bankGoldChangeValue = bankGoldChangeValue;
	}
	
	//set BankGoldAfterChange with  long 
	public void setBankGoldBeforeChange(long bankGoldBeforeChange) {
		BigDecimal decimalGoldCoin = Helper.sub(this.bankGoldBeforeChange, new BigDecimal(this.bankGoldBeforeChange.longValue()));
		this.bankGoldBeforeChange = Helper.add(new BigDecimal(bankGoldBeforeChange), decimalGoldCoin);
	}
	
	//set BankGoldAfterChange with  bigdecimal 
	public void setBankGoldBeforeChange(BigDecimal bankGoldBeforeChange) {
		this.bankGoldBeforeChange = bankGoldBeforeChange;
	}
	
	//set BankGoldAfterChange with  long 
	public void setBankGoldAfterChange(long bankGoldAfterChange) {
		BigDecimal decimalGoldCoin = Helper.sub(this.bankGoldAfterChange, new BigDecimal(this.bankGoldAfterChange.longValue()));
		this.bankGoldAfterChange = Helper.add(new BigDecimal(bankGoldAfterChange), decimalGoldCoin);
	}
	
	//set BankGoldAfterChange with  bigdecimal 
	public void setBankGoldAfterChange(BigDecimal bankGoldAfterChange) {
		this.bankGoldAfterChange = bankGoldAfterChange;
	}
	
	public void setChangeWay(int changeWay) {
		this.changeWay = changeWay;
	}

	public void setChangeWayDesc(String changeWayDesc) {
		this.changeWayDesc = changeWayDesc;
	}
	
	public String getDownlineName() {
		return downlineName;
	}

	public void setDownlineName(String downlineName) {
		this.downlineName = downlineName;
	}

	public Date getRebateDate() {
		return rebateBelongsDate;
	}

	public void setRebateDate(Date rebateDate) {
		this.rebateBelongsDate = rebateDate;
	}
}
